<template>

<div style="padding-top: 20px; background: #F0EEEF;">
  
  <div class="area-list">
    <el-checkbox-group v-model="cityGroup" :min="0" :max="9">
      <el-checkbox-button v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox-button>
    </el-checkbox-group>
   <div style="visibility:hidden;min-height: 36px;"></div>
    <span style="color:red">您还可以选择{{areaNum}}个</span>
  </div>
    <div style="visibility:hidden;min-height: 28px;"></div>
  <div style="padding-bottom: 20px; margin-top: 2vh;">
    <el-row>
      <el-button @click="backToHome">返回首页</el-button>
      <el-button @click="prevStep" v-if="!testUser">上一步</el-button>
      <el-button type="success" @click="nextStep">下一步</el-button>
    </el-row>
  </div>
    <div style="visibility:hidden;min-height: 36px;">
  </div>
</div>
</template>
<script>
import {areaList} from '@/constants/constants'

export default {
  data() {
    return {
      testUser: true,
      cityGroup: [],
      cities: areaList,
      areaNum: 9
    }
  },
  mounted(){
    if (JSON.parse(localStorage.getItem('user')).userType) {
      this.testUser = false
    }
  },
  methods: {
    backToHome() {
      this.$router.push('/')
      this.$store.state.common.stepIndex = 0
    },
    prevStep() {
      this.$router.push('/step/estimatescore')
      this.$store.dispatch('common/prevStep')
    },
    nextStep() {
      this.$store.dispatch('estimate/getAreaSet', this.cityGroup)
      this.$router.push('/step/chooseprofession')
      this.$store.dispatch('common/nextStep')
    }
  },
  watch: {
    cityGroup(val) {
      console.log(this.cityGroup.length, 'cityGroup length')
      this.areaNum = 9 - this.cityGroup.length
    }
  }
}
</script>
<style>
.area-list{
  width: 85%;
  text-align: center;
  padding: 5%;
}
.el-checkbox-button{
  border-radius: 30px;
  cursor: pointer;
  min-width: 90px;
  margin: 20px 0;
}
.el-checkbox-button:last-child .el-checkbox-button__inner{
  border-radius: 30px;

}
.el-checkbox-button__inner{
  border-radius: 30px;
  min-width: 120px;
  max-width: 150px;
}
</style>
